package com.probiz.estore.core.filter;

import java.util.Locale;

import org.springframework.context.i18n.LocaleContextHolder;

import com.probiz.estore.core.datasource.DbContextHolder;

public class ProbizLocaleContextHolder{
	
	/**
	 * 
	 * @param currLocale
	 */
	public static void setLocale(Locale currLocale){
		
		/**
		 * 动态切换数据库
		 */
		if("en".equalsIgnoreCase(currLocale.getLanguage())){
			DbContextHolder.setDbType(currLocale.getLanguage());
		}else if("zh_CN".equalsIgnoreCase(currLocale.getLanguage())){
			DbContextHolder.setDbType(currLocale.getLanguage());
		}else if("zh".equalsIgnoreCase(currLocale.getLanguage())){
			DbContextHolder.setDbType(currLocale.getLanguage());
		}
		
		LocaleContextHolder.setLocale(currLocale);
	}
}
